 var threeSum = function(nums) {
    if(nums.length<3) return []
    nums.sort((a,b) => a-b)
     let res = []
    for(let i=0;i<nums.length-2;i++){
    //去重
   if (i > 0 && nums[i] == nums[i - 1]) continue
    const target = -nums[i]
    let left = i+1;
    let right = nums.length-1
    while(right>left){
        const sum = nums[left] + nums[right]
        if(sum==target){
            res.push([nums[i],nums[left],nums[right]])
            while(right>left&&nums[left]==nums[++left]);
            while(right>left&&nums[right]==nums[--right]);
        }else if(sum < target){
            left++
        }else{
            right--
        }
    }
    }
    return res
}; 
console.log(111);


